import * as actionTypes from './constant';
import { Map } from 'immutable';

const defaultState = Map({
  topTen: [],
  favor: [],
  categorySale: [],
  addressSale: [],
  categoryCount: [],
});

function reducer(state = defaultState, action) {
  switch (action.type) {
    case actionTypes.CHANGE_TOP_TEN:
      return state.set('topTen', action.topTen);
    case actionTypes.CHANGE_FAVOR:
      return state.set('favor', action.favor);
    case actionTypes.CHANGE_CATEGORY_SALE:
      return state.set('categorySale', action.categorySale);
    case actionTypes.CHANGE_ADDRESS_SALE:
      return state.set('addressSale', action.addressSale);
    case actionTypes.CHANGE_CATEGORY_COUNT:
      return state.set('categoryCount', action.categoryCount);
    default:
      return state;
  }
}

export default reducer;
